package cn.iocoder.yudao.module.brokerage.user.pojo.bo;

import cn.iocoder.yudao.framework.common.util.number.MoneyUtils;
import cn.iocoder.yudao.module.api.brokerage.level.enums.BrokerageLevelTypeEnum;
import cn.iocoder.yudao.module.api.brokerage.user.enums.BrokerageLevelWeightEnum;
import cn.iocoder.yudao.module.api.member.agency.enums.AgencyLevelEnum;
import cn.iocoder.yudao.module.api.member.vip.enums.VipLevelEnum;
import com.fasterxml.jackson.annotation.JsonInclude;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

import java.io.Serializable;
import java.util.Objects;

@Schema(description = "推广人员数据汇总 Response VO")
@Data
public class BrokerageUserMonthSummaryBO implements Serializable {

    @Schema(description = "年份")
    private Integer year;

    @Schema(description = "月份")
    private Integer month;

    @Schema(description = "邀请人数")
    private Integer inviteCount;

    @Schema(description = "累计已结算分佣，单位为分")
    private Integer totalMoney;
    @Schema(description = "累计已结算分佣，单位为元")
    private String totalMoneyYuan;

    @SuppressWarnings("unused")
    public String getTotalMoneyYuan() {
        if (totalMoneyYuan == null) {
            totalMoneyYuan = MoneyUtils.fenToYuanStr(getTotalMoney());
        }
        return totalMoneyYuan;
    }

    @Schema(description = "累计待入账分佣，单位为分")
    @JsonInclude(JsonInclude.Include.NON_NULL)
    private Integer totalFreezingMoney;
    @Schema(description = "累计待入账分佣，单位为元")
    @JsonInclude(JsonInclude.Include.NON_NULL)
    private String totalFreezingMoneyYuan;

    @SuppressWarnings("unused")
    public String getTotalFreezingMoneyYuan() {
        if (totalFreezingMoney == null) {
            return null;
        }
        return MoneyUtils.fenToYuanStr(getTotalFreezingMoney());
    }

    @Schema(description = "累计贡献值")
    private Integer totalGrowth;

    @Schema(description = "类型：0-普通用户、1-会员、2-招商人员、3-商家")
    private Integer type;
    @Schema(description = "类型")
    private String typeName;

    @SuppressWarnings("unused")
    public String getTypeName() {
        return BrokerageLevelTypeEnum.valueOf(getType()).getName();
    }

    @Schema(description = "等级权重")
    private Integer levelWeight;
    @Schema(description = "等级权重")
    private String levelWeightName;

    @SuppressWarnings("unused")
    public String getLevelWeightName() {
        if (Objects.equals(getType(), BrokerageLevelTypeEnum.VIP.getValue())) {
            return VipLevelEnum.valueOf(getLevelWeight()).getName();
        }
        if (Objects.equals(getType(), BrokerageLevelTypeEnum.AGENCY.getValue())) {
            return AgencyLevelEnum.valueOf(getLevelWeight()).getName();
        }
        return BrokerageLevelWeightEnum.valueOf(getLevelWeight()).getName();
    }

}